package com.example.demo.service;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.example.demo.constants.API;
import com.example.demo.tools.HttpUtil;
import com.google.gson.JsonObject;

public class TalkService {

    private HttpUtil httpUtil;


    public TalkService(){
        httpUtil = new HttpUtil();
    }

    public void getalltalk(Handler handler){

        new Thread(new Runnable() {
            @Override
            public void run() {
                //通过路由 传入数据 访问后台
                String json = httpUtil.sendRequestByGet(API.ALLTALK+"/"+30);
                //子线程返回数据到主线程
                Message msg = new Message();
                Bundle bundle = new Bundle();
                bundle.putString("result",json);
                msg.setData(bundle);
                //子线程发送数据
                handler.sendMessage(msg);
            }
        }).start();
    }


}
